package ai.leinao.common.domain;

import cn.hutool.core.collection.CollUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 采集数据响应
 *
 * @author zhong.wang
 * @date 2025/8/26
 **/
@Slf4j
@Data
public class GatherData {
    /**
     * 时间戳
     */
    private Date ts;

    /**
     * 部门ID
     */
    private Long deptId;

    /**
     * 站点ID
     */
    private Long stationId;

    /**
     * 站点区域ID
     */
    private Long areaId;

    /**
     * 设备型号ID
     */
    private Long deviceModelId;

    /**
     * 设备ID
     */
    private Long deviceId;

    /**
     * 设备类型
     */
    private String deviceTypeCode;

    /**
     * 设备属性数据
     */
    private Map<String,Object> properties;


    /**
     * 转换为计算上下文
     * @return
     */
    public Map<String,Object> toContext() {
        Map<String,Object> context = new HashMap<>();
        context.put("ts", ts);
        context.put("deptId", deptId);
        context.put("stationId", stationId);
        context.put("areaId", areaId);
        context.put("deviceModelId", deviceModelId);
        context.put("deviceId", deviceId);
        context.put("deviceTypeCode", deviceTypeCode);
       if(CollUtil.isNotEmpty(properties)){
           context.putAll(properties);
       }
       return context;
    }

}
